//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------


using System.Data.Linq;
namespace Mindscape.BackgroundMotion.Core.Model
{
  public sealed class DLinqUnitOfWork : UnitOfWorkBase
  {
    private readonly DataContext _dataContext;

    /// <summary>
    /// Initializes a new instance of the <see cref="DLinqUnitOfWork"/> class.
    /// </summary>
    /// <param name="dataContext">The data context.</param>
    public DLinqUnitOfWork(DataContext dataContext)
    {
      _dataContext = dataContext;
    }

    /// <summary>
    /// Gets the data context.
    /// </summary>
    /// <value>The data context.</value>
    internal DataContext DataContext
    {
      get
      {
        EnsureNotDisposed();

        return _dataContext;
      }
    }

    /// <summary>
    /// Performs the complete.
    /// </summary>
    protected override void PerformComplete()
    {
      _dataContext.SubmitChanges();
    }
  }
}